<?php
require '../Connections/agriculture.php';

$sign="_agriculture";

$hostname='hostname'.$sign;
$username='username'.$sign;
$password='password'.$sign;
$database='database'.$sign;

$hostname=$$hostname;
$username=$$username;
$password=$$password;
$database=$$database;

if(!function_exists('alter')){
	function alter($sql) #函数功能：从表中修改数据:insert\update\delete
	{
		global $hostname,$username,$password,$database;
		
		$conn = @mysql_connect($hostname,$username,$password);
		@mysql_set_charset('utf8',$conn);
		@mysql_select_db($database,$conn);
		$result = @mysql_query($sql);
		($id=@mysql_insert_id($conn)) && $result = $id;
		@mysql_close($conn);
		
		return $result;
	}
}

if(!function_exists('choice')){
	function choice($sql)  #函数功能: 从表中选取数据:select
	{
		global $hostname,$username,$password,$database;
		$output=array();
		$conn = @mysql_connect($hostname,$username,$password);
		@mysql_set_charset('utf8',$conn);
		$result = @mysql_db_query($database,$sql,$conn);
		@mysql_data_seek($result,0);
		while($row = @mysql_fetch_array($result,MYSQL_ASSOC))
		{
			$output[] = $row;
		}
		@mysql_free_result($result);
		@mysql_close($conn);
		
		return $output;
	}
}

if (!function_exists('choice_count')){
	function choice_count($sql){
		global $hostname,$username,$password,$database;
		
		$conn = @mysql_connect($hostname,$username,$password);
		@mysql_select_db($database,$conn);		
		$result = @mysql_query($sql);
		$result = mysql_num_rows($result);
		@mysql_close($conn);
		
		return $result;
	}
}